<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@page import="learninganalytics.UAgentInfo"%>
<%// checken voor 6 verschillende mobile os
	String userAgent = request.getHeader("User-Agent");
	String httpAccept = request.getHeader("Accept");
	UAgentInfo detector = new UAgentInfo(userAgent, httpAccept);
	if (detector.detectIos()) {
        response.sendRedirect("/index-mobile.jsp");
    }else if(detector.detectAndroid()){
		response.sendRedirect("/index-mobile.jsp");
		
	}else if(detector.detectBlackBerry()){
		response.sendRedirect("/index-mobile.jsp");
		
	}else if(detector.detectSymbianOS()){
		response.sendRedirect("/index-mobile.jsp");
		
	}else if(detector.detectWindowsPhone7()){
		response.sendRedirect("/index-mobile.jsp");
	}else if(detector.detectWindowsMobile()){
		response.sendRedirect("/index-mobile.jsp");
	}
%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="managesystem.Student"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="/images/favicon.ico" rel="icon" type="image/x-icon" />
<link href="/styles/style.css" rel="stylesheet" type="text/css">
<link href="/styles/notify.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/plot2/plot.css" />
<script type="text/javascript" src="/plot2/plots.js"></script>	
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>

<%
	String message = (String) session.getAttribute("message");
	String error = (String) session.getAttribute("error");
	session.setAttribute("message", null);
	session.setAttribute("error", null);
%>
<title>Learning Application</title>

<%
	Student currStud = (Student) session.getAttribute("currStud");
	if(currStud != null && currStud.getUnfinishedActivity() != null)
	{
		String Errormessage = "<br />There's an unfinished activity. <a href=\"/index.jsp?id=resume\">Resume</a>";
		Errormessage = Errormessage +  " <a href=\"/cancelAct\">Or cancel</a>";
		error = (error == null) ? Errormessage : error + Errormessage;
	}
%>

</head>

<body>
	<%
		if (error != null) {
	%>
	
		<div class="error" style="display:none;">
			<span><%=error%></span> <a href="#" class="close-notify">Close</a>
		</div>
	
	<script type="text/javascript">
			$('.error').slideToggle("slow");
            $('.error a.close-notify').click(function () {
            	$('.error').slideToggle("slow");
                return false;
            });
        
    </script>
	<%
		}
	%>
	<%
		if (message != null) {
	%>
	
		<div class="success" style="display:none;">
			<span><%=message%></span> <a href="#" class="close-notify">Close</a>
		</div>
	
	<script type="text/javascript">
			$('.success').slideToggle("slow");
            $('.success a.close-notify').click(function () {
            	$('.success').slideToggle("slow");
                return false;
            });
        
    </script>
	<%
		}
	%>
	<div id="header">
		<%
			if (currStud == null) {
				pageContext.include("inc/loginpanel.jsp");

			} else {
				pageContext.include("inc/toolbar.jsp");
			}
		%>
		<div class="logo">
			<a href="/">Learning Application</a>
		</div>

	</div>
	<div id="nav"></div>
	<div id="main">
		<ul id="horizontaleNav">
			<li class="tab"><a href="/index.jsp?id=home">Home</a></li>
			<li class="tab"><a href="/index.jsp?id=about">About</a></li>

		</ul>
		<%
			String pageID = request.getParameter("id");
			ArrayList<String> pages = new ArrayList<String>();
			pages.add("home");
			pages.add("about");
			pages.add("register");
			pages.add("milestones");
			pages.add("start");
			pages.add("ucp");
			pages.add("track");
			pages.add("school");
			pages.add("other");
			pages.add("dashboard");
			pages.add("resume");
			pages.add("plot");

			if (currStud != null) {

				if (pageID == null) {

					pageContext.include("/inc/home.jsp");
				
				} else if (pageID.equals("plot")) {
					pageContext.include("/plot2/4plots_main.jsp");
					
					
				} else if (pages.contains(pageID)) {
					pageID = "/inc/" + pageID + ".jsp";
					pageContext.include(pageID);
				}

				else {
					pageContext.include("/inc/404.jsp");
				}

			} else {

				if (pageID != null && pageID.equals("register")) {
					pageContext.include("/inc/register.jsp", true);
				}
				else if(pageID!=null && pageID.equals("about")){
					pageContext.include("/inc/about.jsp",true);
				}
				else {
					pageContext.include("/inc/login.jsp", true);
				}
				
				
			}
			%>
	</div>
	<div class=footer>
		<p>
			Copyright (c) All Rights Reserved. <a href="cw2011a2.wordpress.com" target=_blank>Team CWA2</a> & <a href="http://www.kuleuven.be" target=_blank>KU Leuven</a>
		</p>
		<p>
			This site is best viewed with <a
				href="http://www.mozilla.org/en-US/firefox/new/" target=_blank>Firefox</a>
			or <a
				href="http://www.google.com/chrome/index.html?hl=en&brand=CHMB&utm_campaign=nl&utm_source=nl-ha-emea-be-sk&utm_medium=ha"
				target=_blank>Chrome</a>
		</p>	
	</div>
</body>
</html>